from flask import Flask, render_template,g

app = Flask(__name__)


@app.route('/')
# def hello_world():  # put application's code here
#     return 'Hello World!'
def get_user():
    user_id = '001'           	# 设置用户id
    user_name = 'flask'    	# 设置用户名称
    g.user_id = user_id      # 将用户id保存到g对象中
    g.user_name = user_name # 将用户名称保存到g对象中
    result = db_query()
    return f'{result}'
def db_query():
    user_id = g.user_id    # 使用g对象获取用户id
    user_name = g.user_name  # 使用g对象获取用户名称
    return f'{user_id}:{user_name}'


@app.route('/main/<num>',methods=['GET', 'POST'])
def main(num):
    return render_template('index.html',num = num)

if __name__ == '__main__':
    app.run()
